<template>
  <div class="center-energy-report">
    <dv-loading v-if="loading"></dv-loading>
    <Aistart
      v-else
      :lsjStatedata="lsjStatedata"
      :topitemdata="topitemdata"
      :copChartlist="copChartlist"
    />
  </div>
</template>
<script>
import Aistart from "../../components/aistart/Aistart.vue";
import { topitemapi, lsjStateapi, echarsapi } from "../../api/base8090.js";
import { mapState } from "vuex";
export default {
  name: "aistart",
  components: {
    Aistart,
  },
  created() {
    this.timer = setInterval(() => {
      if (document.readyState === "complete") {
        this.loading = false;
        window.clearInterval(this.timer);
      }
    }, 1000);
    this.initData();
  },
  data() {
    return {
       loading: true,
      timer: null,
      topitemdata: {},
      lsjStatedata: [],
      copChartlist: [],
      queryParmas: {
        stationCode: sessionStorage.getItem("stationCode"),
      },
    };
  },
  methods: {
    initData() {
      this.topitemdata = {};
      this.lsjStatedata = [];
      this.copChartlist = [];
      //站厅 站台 外气 实时制冷量 数据
      topitemapi(this.queryParmas).then((res) => {
        this.topitemdata = res.data;
      });
      // 冷水机列表
      lsjStateapi(this.queryParmas).then((res) => {
        this.lsjStatedata = res.data;
      });
      // cop图表列表
      echarsapi(this.queryParmas).then((res) => {
        this.copChartlist = res.data;
      });
    },
  },
   computed: {
    ...mapState(["stationCode"]),
  },
  watch: {
    stationCode(newVal, oldVal) {
      if (newVal != oldVal) {
        this.queryParmas.stationCode = newVal;
        
        this.initData();
      }
    },
  },
};
</script>
<style lang="less" scoped>
.center-energy-report {
  width: 100%;
  height: 100%;
}
</style>
